import Vue from "vue"
import Vuex from "vuex"
import indexModule from "./modules/index.js"
import pickUpLocationModule from "./modules/pickUpLocation.js"
import categoryModule from "./modules/category.js"
import cartModule from "./modules/cart.js"
// 引入持久化插件
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)
//这里必须使用new
export default new Vuex.Store({
	modules:{
		indexModule,
		pickUpLocationModule,
		categoryModule,
		cartModule
	},
	plugins:[createPersistedState({
		storage:{
			getItem:(key)=>uni.getStorageSync(key),
			setItem:(key,value)=>uni.setStorageSync(key,value),
			removeItem:(key)=>uni.removeStorageSync(key)
		}
	})]
})
